// init
import { init } from '../../util/app'
// plugins
import createLoading from 'dva-loading'
import createEffectLock from '../../plugin/effectLock'
import { createLoginSession } from '../../plugin/loginSession'
import { createWebLocalStore, getWebState } from '../../plugin/webLocalStore'
// models
import login from '../login/model/login'
import register from '../login/model/register'
import forgetPassword from '../login/model/forgetPassword'
import system from './model/system'
import user from './model/user'
import role from './model/role'
import permission from './model/permission'
import channel from './model/channel'
// router
import router from './router'
// css
import './index.css'

const WEB_STATE_USER_SERVER = 'WEB_STATE_USER_SERVER'
let initialState = getWebState(WEB_STATE_USER_SERVER) || {
    login: {
        channel: 'a3384a9ca39efb36822d0b10b62fbd6c',
		loginRedirect: '/system',
		logoutRedirect: '/'
    }
}
// 重置插件属性
if(initialState.loading) delete initialState.loading// 重置loading
if(initialState.effectLock) delete initialState.effectLock// 重置effectlock

const dvaApp = init({
	initialState,
    plugins: [
        createLoading(),
        createEffectLock(),
        createLoginSession(),
        createWebLocalStore(WEB_STATE_USER_SERVER),
    ],
    models: [
        login,
        register,
        forgetPassword,
        system,
        user,
        role,
        permission,
        channel,
    ],
    router,
    start: '#root'
})